package com.zxy.study.utils;

import android.app.ActivityManager;
import android.content.Context;
import android.util.Log;

public class LifeCycleLog {
    private final static String TAG = "lifecycle";

    public static void logCreate(Class clazz){
        Log.d(TAG,clazz.getSimpleName()+"  onCreate");
    }

    public static void logStart(Class clazz){
        Log.d(TAG,clazz.getSimpleName()+"  onStart");
    }

    public static void logReStart(Class clazz){Log.d(TAG,clazz.getSimpleName()+"  onReStart");}

    public static void logResume(Class clazz){
        Log.d(TAG,clazz.getSimpleName()+"  onResume");
    }

    public static void logPause(Class clazz){
        Log.d(TAG,clazz.getSimpleName()+"  onPause");
    }

    public static void logStop(Class clazz){
        Log.d(TAG,clazz.getSimpleName()+"  onStop");
    }

    public static void logDestroy(Class clazz){
        Log.d(TAG,clazz.getSimpleName()+"  onDestroy");
    }

    public static void logReStart(Class clazz){Log.d(TAG,clazz.getSimpleName()+"  onReStart");}

    public static void logSaveInstanceState(Class clazz){
        Log.d(TAG,clazz.getSimpleName()+"  onSaveInstanceState");
    }

    public static void logRestoreInstanceState(Class clazz){
        Log.d(TAG,clazz.getSimpleName()+"  onRestoreInstanceState");
    }

    public static void logCurTaskInfo(Context context){
        try {
            ActivityManager am = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
            ActivityManager.RunningTaskInfo info = am.getRunningTasks(1).get(0);
            Log.d(TAG,"taskId="+info.taskId);
        }catch (Error e){
//            e.printStackTrace();
        }
    }
}
